//
//  SLCircleTitleComponent.m
//  SulitLoanDemo
//
//  Created by 虞嘉伟 on 2025/2/23.
//

#import "SLCircleTitleComponent.h"
#import <YYKit.h>
#import <Masonry.h>


@implementation SLCircleTitleComponent

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        _themeColor = UIColor.whiteColor;
        
        [self addSubview:self.circle];
        [self addSubview:self.titleLabel];
       
        [self.circle mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).inset(0);
            make.width.height.mas_equalTo(15);
            make.centerY.equalTo(self);
        }];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.circle.mas_right).offset(8);
            make.right.equalTo(self);
            make.centerY.equalTo(self.circle);
        }];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.circle.layer.cornerRadius = CGRectGetHeight(self.circle.bounds)*0.5;
}
- (void)drawRect:(CGRect)rect {
    [super drawRect:rect];
    _circle.layer.borderColor = _themeColor.CGColor;
    _titleLabel.textColor = _themeColor;
}

- (void)setThemeColor:(UIColor *)themeColor {
    _themeColor = themeColor;
    [self setNeedsDisplay];
}

- (UIView *)circle {
    if (!_circle) {
        _circle = [UIView new];
        _circle.layer.borderColor = UIColor.whiteColor.CGColor;
        _circle.layer.borderWidth = 1.5;
    }
    return _circle;
}
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.text = @"Id Card Portrait Face Photo";
        _titleLabel.textColor = UIColor.whiteColor;
    }
    return _titleLabel;
}
@end
